package com.example.demo.controller;

import com.example.demo.entity.Location;
import com.example.demo.entity.Person;
import com.example.demo.repository.PersonRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;

/**
 * Created by Administrator on 2018/06/13 0013.
 */

/*
@RestController
public class TestController {

    @Autowired
    PersonRepository personRepository;


    @RequestMapping("save")
    public Person save() {
        Person p = new Person("张海洋", 27);
        Collection<Location> locations = new LinkedHashSet<>();
        Location l1 = new Location("北京", "2009");
        Location l2 = new Location("上海", "2010");
        Location l3 = new Location("广州", "2011");
        Location l4 = new Location("深圳", "2012");
        locations.add(l1);
        locations.add(l2);
        locations.add(l3);
        locations.add(l4);
        p.setLocations(locations);
        return personRepository.save(p);
    }

    @RequestMapping("q1")
    public Person q1(String name) {
        return personRepository.findByName(name);
    }

    @RequestMapping("q2")
    public List<Person> q2(Integer age) {
        return personRepository.withQueryFindByAge(age);
    }
}
*/
